Conditions | 5 |
Total Lines | 19 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5 |
Changes | 0 |
1 | // Comparison functions for different data types |
||
2 | 1 | export function compareSortablePrimitives( |
|
3 | a: unknown, |
||
4 | b: unknown, |
||
5 | ascending: boolean |
||
6 | ): number { |
||
7 | 168 | if (typeof a === 'string' && typeof b === 'string') { |
|
8 | 40 | return ascending ? a.localeCompare(b) : b.localeCompare(a); |
|
9 | } |
||
10 | |||
11 | 128 | if (typeof a === 'number' && typeof b === 'number') { |
|
12 | 83 | return compareNumbers(a, b, ascending); |
|
13 | } |
||
14 | |||
15 | 45 | if (typeof a === 'boolean' && typeof b === 'boolean') { |
|
16 | 21 | return compareBooleans(a, b, ascending); |
|
17 | } |
||
18 | |||
19 | 24 | return 0; // Maintain order for other primitives |
|
20 | } |
||
60 |